from math import log

from pandas import Timestamp


def cn_wt(edges1, edges2, start_time):
    measure = 0
    for edge in edges1 + edges2:
        decay = time_decay(edge.time, start_time)
        score = decay * edge.weight
        measure += score

    return measure


def time_decay(time, start_time, k=3):
    if isinstance(time, Timestamp):
        time = time.year
    decay = log(time - start_time + k)
    return decay
